package com.cat.dataStructure03;

class Solution12 {
    public int[] smallestSubarrays(int[] nums) {
        int n = nums.length;
        int [] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int x = nums[i];
            ans[i] = 1;
            // 不一样是一个单调递增的过程 
            for (int j = i - 1; j >= 0 && (nums[j] | x) != nums[j]; j--) {
                nums[j] |= x;
                ans[j] = i - j + 1;
            }
        }

        return ans;
    }
}